package niuketitle.parameterpass;

/**
 * @author wys
 * created in 14:26 2019/3/1
 */
public class Parameter {

    static int a = 10;

    static void add(int a) {
        a++;
    }

    static void ageAdd(User user) {
        user.age++;
    }

    public static void main(String args[]) {

        User user = new User();

        // user1是引用
        User user1 = user;

        // 传进去的也是引用，不过值会修改
        add(a);
        System.out.println("a = " + a);

        // 传进去的也是引用，不过值会修改
        ageAdd(user);
        System.out.println("us.age = " + user.age);

//        ageAdd(user1);
//        System.out.println("user1.age = " + user1.age);


    }

}

class User {

    String name = "wang";
    int age = 22;

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }
}
